//
//  OrderListModel.m
//  ChineseCollegeStudentsNetwork
//
//  Created by Zheng on 2019/3/22.
//  Copyright © 2019 刘喆. All rights reserved.
//

#import "OrderListModel.h"

@implementation OrderListModel

- (id)mj_newValueFromOldValue:(id)oldValue property:(MJProperty *)property {
    if ([self cx_isEmpty:oldValue]) {
        return @" ";
    }
    return oldValue;
}

- (BOOL)cx_isEmpty:(NSString *)text {
    if ([text isEqual:[NSNull null]]) {
        return YES;
    }
    else if ([text isKindOfClass:[NSNull class]]) {
        return YES;
    } else if (text == nil) {
        return YES;
    }
    return NO;
}


+ (BOOL)propertyIsOptional:(NSString *)propertyName {
    return YES;
}

+ (NSDictionary *)mj_objectClassInArray {
    return @{@"cartInfoList":@"OrderListModel"};
}

- (NSString<Optional> *)imageUrl {
    if ([_imageUrl containsString:@"http:"]) {
        return _imageUrl;
    } else {
        if ([_imageUrl containsString:@"@"]) {
            _imageUrl = [_imageUrl substringWithRange:NSMakeRange(1, _imageUrl.length-1)];
        }
        
        return [NSString stringWithFormat:@"%@%@",kBase_URL,_imageUrl];
    }
}

@end
